<?php

/**
 * \file
 * Classe listant les resultats d'une recherche avec pagination.
 */

namespace pilar\Scaffolding /* \cond */ ; /* \endcond */
{

/**
 * Bloc de listing de resultats de recherche.
 *
 * \since 24/03/2009
 * \author Dirk MARSKI <dirk.marski@gmail.com>
 */
class ObjectCollectionListing extends Pagination {


protected function loadDefaultParams() {
 parent::loadDefaultParams();

 $this->params->define(array(
  'objects' => ''  // Collection d'objets dont on veut le listing.
 ));
}


protected function initialize() {
 parent::initialize();

 $this->newArea('Objects');
}


public function buildContentRoot($domDoc) {
 $domSRL = $domDoc->createElement('ObjectCollectionListing');

 // Données :
  foreach ($this->_members as $object) {
   $this->area('Objects')->pushSubBlocks(
    new Datasheet(array('object' => $object))
   );
  }
  $domSRL->appendChild($this->area('Objects')->domNode($domDoc));

 // Pagination :
  $domSRL->appendChild(parent::buildContentRoot($domDoc));

 return $domSRL;
}


protected function getMembers() {
 $objects = $this->get('objects');

 if ($this->get('paginationLength') > 0) {
  $objects->limit($this->get('paginationLength'), $this->_offset);
 }

 foreach ($objects as $object) {
  $this->_members[] = $object;
 }
}


} // Class.

} // Namespace.

?>
